package com.work.csms.service;

import com.work.csms.dao.Fix;
import com.work.csms.dao.Order;
import com.work.csms.mapper.FixMapper;
import com.work.csms.pojo.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FixService {

    @Autowired(required = false)
    private FixMapper fixMapper;

    public Map<String, Object> page(Fix fix, PageParam pageParam) throws Exception {
        Map<String, Object> result = new HashMap<>();
        Integer count = fixMapper.count(fix.getId());
        List<Fix> page = fixMapper.page(fix.getDes(), fix.getName(), (pageParam.getPageNo() - 1) * pageParam.getPageSize(), pageParam.getPageSize());
        result.put("count", count);
        result.put("pageSize", pageParam.getPageSize());
        result.put("pageNo", pageParam.getPageNo());
        result.put("data", page);
        return result;
    }

    public List<Fix> list(Fix fix) throws Exception {
        return fixMapper.list(fix);
    }

    public Integer getFixCountByDate(Fix fix) {
        return fixMapper.getFixCountByDate(fix);
    }


    public Fix getFixById(Integer id) throws Exception {
        return fixMapper.getFixById(id);
    }

    public void save(Fix fix) throws Exception {
        fixMapper.save(fix);
    }

    public void update(Fix fix) throws Exception {
        fixMapper.update(fix);
    }

    public void deleted(Integer id) throws Exception {
        fixMapper.deleted(id);
    }

}
